services:
  zookeeper:
    container_name: zookeeper
    image: confluentinc/cp-zookeeper:7.4.4
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
    networks:
      - backend
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    networks:
      - backend
  grafana:
    image: grafana/grafana-oss
    container_name: grafana
    ports:
      - "3000:3000"
    networks:
      - backend
  kafka:
    container_name: kafka
    image: confluentinc/cp-kafka:7.4.4
    depends_on:
      - zookeeper
    networks:
      - backend
    ports:
      - "9092:9092"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9093,PLAINTEXT_HOST://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093,PLAINTEXT_HOST://0.0.0.0:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    volumes:
      - kafka:/var/lib/kafka/data

  postgresql:
    image: postgres:16
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: scrapper
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - postgresql:/var/lib/postgresql/data
    networks:
      - backend
  liquibase-migrations:
    image: liquibase/liquibase:4.25
    depends_on:
      - postgresql
    command:
      - --changelog-file=master.xml
      - --driver=org.postgresql.Driver
      - --url=jdbc:postgresql://postgresql:5432/scrapper
      - --username=postgres
      - --password=postgres
      - update
    volumes:
      - ./scrapper/src/main/resources/migrations/:/liquibase/changelog
    networks:
      - backend


volumes:
  postgresql: { }
  kafka: { }

networks:
  backend: { }


